package com.test.videoplayer;


import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.dueeeke.videoplayer.exo.ExoMediaPlayerFactory;
import com.dueeeke.videoplayer.ijk.IjkPlayerFactory;
import com.test.videoplayer.activity.rabbit.RabbitActivity;
import com.test.videoplayer.activity.test.TestActivity;
import com.test.videoplayer.activity.timer.TimerActivity;
import com.test.videoplayer.helper.Utils;
import com.test.videoplayer.activity.play.DKActivity;

public class MainActivity extends AppCompatActivity implements View.OnClickListener {
    Button btnGV,btnDK,btnVp,btnTest,btnTimer;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
    }
    @SuppressLint("SetTextI18n")
    private void init() {
        TextView mCurrentPlayer = findViewById(R.id.curr_player);
        btnGV = findViewById(R.id.btnGV);
        btnDK = findViewById(R.id.btnDK);
        btnVp = findViewById(R.id.btnVp);
        btnTest = findViewById(R.id.btnTest);
        btnTimer = findViewById(R.id.btnTimer);
        btnGV.setOnClickListener(this);
        btnDK.setOnClickListener(this);
        btnVp.setOnClickListener(this);
        btnTest.setOnClickListener(this);
        btnTimer.setOnClickListener(this);
        Object playerFactory = Utils.getCurrentPlayerFactory();
        String msg = "当前播放核心：";
        if (playerFactory instanceof ExoMediaPlayerFactory) {
            mCurrentPlayer.setText(msg + "ExoPlayer");
        }else if(playerFactory instanceof IjkPlayerFactory){
            mCurrentPlayer.setText(msg + "ijkPlayer");
        }else{
            mCurrentPlayer.setText(msg + "MediaPlayer");
        }
    }

    @Override
    public void onClick(View view) {
        int id = view.getId();
        Intent intent = new Intent();
        switch (id){
            case R.id.btnGV: {
                //intent.setClass(this,GVActivity.class);
                startActivity(intent);
                break;
            }
            case R.id.btnDK: {
                intent.setClass(this, DKActivity.class);
                startActivity(intent);
                break;
            }
            case R.id.btnVp: {
                intent.setClass(this, RabbitActivity.class);
                startActivity(intent);
                break;
            }
            case R.id.btnTest: {
                intent.setClass(this, TestActivity.class);
                startActivity(intent);
                break;
            }
            case R.id.btnTimer: {
                intent.setClass(this, TimerActivity.class);
                startActivity(intent);
                break;
            }
            default:
                break;
        }
    }
}
